import 'package:flutter_app/net_data/entity/banner_entity.dart';

bannerEntityFromJson(BannerEntity data, Map<String, dynamic> json) {
	if (json['content'] != null) {
		data.content = BannerContent().fromJson(json['content']);
	}
	if (json['msg'] != null) {
		data.msg = json['msg'].toString();
	}
	if (json['status'] != null) {
		data.status = json['status'] is String
				? int.tryParse(json['status'])
				: json['status'].toInt();
	}
	if (json['uid'] != null) {
		data.uid = json['uid'].toString();
	}
	return data;
}

Map<String, dynamic> bannerEntityToJson(BannerEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['content'] = entity.content?.toJson();
	data['msg'] = entity.msg;
	data['status'] = entity.status;
	data['uid'] = entity.uid;
	return data;
}

bannerContentFromJson(BannerContent data, Map<String, dynamic> json) {
	if (json['code'] != null) {
		data.code = json['code'] is String
				? int.tryParse(json['code'])
				: json['code'].toInt();
	}
	if (json['codeDesc'] != null) {
		data.codeDesc = json['codeDesc'].toString();
	}
	if (json['data'] != null) {
		data.data = BannerContentData().fromJson(json['data']);
	}
	return data;
}

Map<String, dynamic> bannerContentToJson(BannerContent entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['code'] = entity.code;
	data['codeDesc'] = entity.codeDesc;
	data['data'] = entity.data?.toJson();
	return data;
}

bannerContentDataFromJson(BannerContentData data, Map<String, dynamic> json) {
	if (json['list'] != null) {
		data.xList = (json['list'] as List).map((v) => BannerContentDataList().fromJson(v)).toList();
	}
	if (json['pageStatus'] != null) {
		data.pageStatus = json['pageStatus'];
	}
	if (json['total'] != null) {
		data.total = json['total'] is String
				? int.tryParse(json['total'])
				: json['total'].toInt();
	}
	return data;
}

Map<String, dynamic> bannerContentDataToJson(BannerContentData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['list'] =  entity.xList?.map((v) => v.toJson())?.toList();
	data['pageStatus'] = entity.pageStatus;
	data['total'] = entity.total;
	return data;
}

bannerContentDataListFromJson(BannerContentDataList data, Map<String, dynamic> json) {
	if (json['bannerId'] != null) {
		data.bannerId = json['bannerId'] is String
				? int.tryParse(json['bannerId'])
				: json['bannerId'].toInt();
	}
	if (json['bannerType'] != null) {
		data.bannerType = json['bannerType'] is String
				? int.tryParse(json['bannerType'])
				: json['bannerType'].toInt();
	}
	if (json['imgLink'] != null) {
		data.imgLink = json['imgLink'].toString();
	}
	if (json['imgUrl'] != null) {
		data.imgUrl = json['imgUrl'].toString();
	}
	return data;
}

Map<String, dynamic> bannerContentDataListToJson(BannerContentDataList entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['bannerId'] = entity.bannerId;
	data['bannerType'] = entity.bannerType;
	data['imgLink'] = entity.imgLink;
	data['imgUrl'] = entity.imgUrl;
	return data;
}